﻿Imports System.Data
Imports System.Data.Odbc
Partial Class countcalls
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Dim dv As New DataView
        Dim number As String

        number = ""

        Dim sConString As String = "DRIVER={MySQL ODBC 5.1 Driver}; SERVER=192.168.1.241; DATABASE=asteriskcdrdb; UID=root; PASSWORD=passw0rd; OPTION=3"
        Dim oConnection As OdbcConnection = New OdbcConnection(sConString)
        Dim sSQL As String = "SELECT COUNT(*) as Expr FROM cdr WHERE src != '9107952280' ORDER BY calldate DESC LIMIT 100"
        Dim oDataAdapter As OdbcDataAdapter = New OdbcDataAdapter(sSQL, oConnection)
        Dim oDataSet As DataSet = New DataSet()
        oDataAdapter.Fill(oDataSet)
        dv.Table = oDataSet.Tables(0)

        number = dv(0)("Expr")

        Response.Write(number)
        Response.ContentType = "text/plain"
        Response.Flush()
        Response.End()
    End Sub
End Class
